package com.tanhua.server.controller;

import com.tanhua.commons.vo.HuanXinUser;
import com.tanhua.server.utils.ThreadLocalUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/huanxin")
@Slf4j
public class HuanXinController {
    //注入TheadLocalUtils
    @Autowired
    private ThreadLocalUtils threadLocalUtils;


    /**
     * 获取当前登陆的用户名与密码，用于环信的登陆
     * @return
     */
    @GetMapping("/user")
    public ResponseEntity<HuanXinUser> getLoginHuanXinUser(){
        log.debug("----------------------获得环信登录的用户名和密码----------------------");
        HuanXinUser user = new HuanXinUser(threadLocalUtils.getUserId().toString(), "123456",String.format("花开堪折只需折 莫待无花空折枝_%d",100));
        return ResponseEntity.ok(user);
    }

}
